let Utils = require("../../../framework/js/utils");

window.AUI.customCompoents.define("aui-checkboxgroup", class extends window.AUI.BaseComponent {
    constructor(name) {
        super(name);
        this.props = {
            checkboxs: {
                type: Array
            },
            value: {
                required: true
            },
            inline: {
                type: Boolean,
                default: true
            }
        };
        this.methods = {
            handleChange(e) {
                var self = this;
                self.$emit("input", self.checks);
            }
        }
    }
    _template() {
        var self = this;
return `<div class="${self._name}">
    <div class="checkbox">
        <label :class="{'checkbox-inline': inline}" v-for="checkbox in checkboxs">           
            <input type="checkbox" :name="checkboxname" @change="handleChange" v-model="checks" :checked="checks.indexOf(checkbox.value) > -1" :value="checkbox.value">
            <span v-html="checkbox.label"></span>
        </label>           
    </div>
</div>`;
    }
    _data() {
        var ret = {};
        ret.checkboxname = Utils.uniqueSelector("checkbox_");
        ret.checks = [];
        ret.s = 1;
        return ret;
    }
    _mounted() {
        this.checks = this.value;
    }
});